//
//  LSZEmptyDataVC.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/6/6.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZEmptyDataVC.h"
@interface LSZEmptyDataVC ()
@property(nonatomic,strong) NSString * fromWhichInterfaceVC;//从哪个界面过里的
@end
@implementation LSZEmptyDataVC
{
    UIImageView * imageViewKong;
}
#pragma mark  - 从哪个界面过里的  过来界面的VC
-(void)fromWhichInterface:(NSString *)string
{
    self.fromWhichInterfaceVC = string;
}
- (instancetype)init {
    self = [super init];
    if (self) {
        self.frame = [UIScreen mainScreen].bounds;
 
        imageViewKong = [[UIImageView alloc]init];
        imageViewKong.image = [UIImage imageNamed:@"感叹号"];
        [self addSubview:imageViewKong];
        imageViewKong.frame = CGRectMake((ScreenWidth-44)/2,250,44 , 44);
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(imageViewKong.frame)+20, ScreenWidth, 20)];
        label.text = @"您的账号在别的地方登录,请重新登录!";
        label.textColor = RGBColor(212, 212, 212);
        label.textAlignment = NSTextAlignmentCenter;
        [self addSubview:label];
        
        UIButton * butOk = [[UIButton alloc]initWithFrame:CGRectMake((ScreenWidth-150)/2, CGRectGetMaxY(label.frame)+30, 150, 40)];
        butOk.backgroundColor = [UIColor redColor];
        [butOk.layer setMasksToBounds:YES];
        [butOk.layer setCornerRadius:4];
        [butOk setTitle:@"重新登录" forState:UIControlStateNormal];
        [butOk setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [butOk addTarget:self action:@selector(clickBut) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:butOk];
        
    }
    return self;
}
-(void)clickBut
{
    NSString * strDelete = [NSString stringWithFormat:@"%@Login",self.fromWhichInterfaceVC];
    NSNotification * notificationDelete =[NSNotification notificationWithName:strDelete object:nil userInfo:nil];
    [[NSNotificationCenter defaultCenter] postNotification:notificationDelete];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:strDelete object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [self RemoveAllSubviewsDelete];
}
- (void)showWithView:(UIView *)view
{
    [view addSubview:self];
}
 -(void)RemoveAllSubviewsDelete
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [self removeFromSuperview];
}
@end
